package com.example.mylibrary.data;

import com.example.mylibrary.greendao.DaoSession;
import com.example.mylibrary.greendao.ItemDao;
import com.example.mylibrary.greendao.ItemGropDao;
import com.example.mylibrary.greendao.ScheduleDao;
import com.example.mylibrary.greendao.SortDao;

import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.NotNull;
import org.greenrobot.greendao.annotation.ToOne;


/**
 * Created by Administrator on 2017/12/11.
 * 项目分组表
 */
@Entity
public class ItemGrop {
    @Id(autoincrement = true)
    private  Long   itemGropID;

    private  long   scheduleID;
    @ToOne(joinProperty = "scheduleID")
    private Schedule scheduleid;

    private  int   sex;    //0-不分男女 1-男子 2-女子

    //组别id
    private  long   sortID;
    @ToOne(joinProperty = "sortID")
    private Sort sortid;

    //项目id
    private  long   itemID;
    @ToOne(joinProperty = "itemID")
    private Item itemid;

    //组号
    private  int   gropNo;

    private int race;

    //分组类型  0-正常 1-补考
    @NotNull private  int   gropType;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    @Generated(hash = 327571623)
    private transient ItemGropDao myDao;

    @Generated(hash = 1652846505)
    public ItemGrop(Long itemGropID, long scheduleID, int sex, long sortID, long itemID, int gropNo,
            int race, int gropType) {
        this.itemGropID = itemGropID;
        this.scheduleID = scheduleID;
        this.sex = sex;
        this.sortID = sortID;
        this.itemID = itemID;
        this.gropNo = gropNo;
        this.race = race;
        this.gropType = gropType;
    }

    @Generated(hash = 1678391767)
    public ItemGrop() {
    }

    public Long getItemGropID() {
        return this.itemGropID;
    }

    public void setItemGropID(Long itemGropID) {
        this.itemGropID = itemGropID;
    }

    public long getScheduleID() {
        return this.scheduleID;
    }

    public void setScheduleID(long scheduleID) {
        this.scheduleID = scheduleID;
    }

    public int getSex() {
        return this.sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public long getSortID() {
        return this.sortID;
    }

    public void setSortID(long sortID) {
        this.sortID = sortID;
    }

    public long getItemID() {
        return this.itemID;
    }

    public void setItemID(long itemID) {
        this.itemID = itemID;
    }

    public int getGropNo() {
        return this.gropNo;
    }

    public void setGropNo(int gropNo) {
        this.gropNo = gropNo;
    }

    public int getGropType() {
        return this.gropType;
    }

    public void setGropType(int gropType) {
        this.gropType = gropType;
    }

    @Generated(hash = 2099324693)
    private transient Long scheduleid__resolvedKey;

    /** To-one relationship, resolved on first access. */
    @Generated(hash = 1282423867)
    public Schedule getScheduleid() {
        long __key = this.scheduleID;
        if (scheduleid__resolvedKey == null
                || !scheduleid__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            ScheduleDao targetDao = daoSession.getScheduleDao();
            Schedule scheduleidNew = targetDao.load(__key);
            synchronized (this) {
                scheduleid = scheduleidNew;
                scheduleid__resolvedKey = __key;
            }
        }
        return scheduleid;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 674269066)
    public void setScheduleid(@NotNull Schedule scheduleid) {
        if (scheduleid == null) {
            throw new DaoException(
                    "To-one property 'scheduleID' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.scheduleid = scheduleid;
            scheduleID = scheduleid.getScheduleID();
            scheduleid__resolvedKey = scheduleID;
        }
    }

    @Generated(hash = 339336192)
    private transient Long sortid__resolvedKey;

    /** To-one relationship, resolved on first access. */
    @Generated(hash = 1398446010)
    public Sort getSortid() {
        long __key = this.sortID;
        if (sortid__resolvedKey == null || !sortid__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            SortDao targetDao = daoSession.getSortDao();
            Sort sortidNew = targetDao.load(__key);
            synchronized (this) {
                sortid = sortidNew;
                sortid__resolvedKey = __key;
            }
        }
        return sortid;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1542909416)
    public void setSortid(@NotNull Sort sortid) {
        if (sortid == null) {
            throw new DaoException(
                    "To-one property 'sortID' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.sortid = sortid;
            sortID = sortid.getSortID();
            sortid__resolvedKey = sortID;
        }
    }

    @Generated(hash = 1993510474)
    private transient Long itemid__resolvedKey;

    /** To-one relationship, resolved on first access. */
    @Generated(hash = 628937880)
    public Item getItemid() {
        long __key = this.itemID;
        if (itemid__resolvedKey == null || !itemid__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            ItemDao targetDao = daoSession.getItemDao();
            Item itemidNew = targetDao.load(__key);
            synchronized (this) {
                itemid = itemidNew;
                itemid__resolvedKey = __key;
            }
        }
        return itemid;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 495097744)
    public void setItemid(@NotNull Item itemid) {
        if (itemid == null) {
            throw new DaoException(
                    "To-one property 'itemID' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.itemid = itemid;
            itemID = itemid.getItemID();
            itemid__resolvedKey = itemID;
        }
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 981208904)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getItemGropDao() : null;
    }

    public int getRace() {
        return this.race;
    }

    public void setRace(int race) {
        this.race = race;
    }


}
